-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Resource Format Auto Detect #1369
Conversation
- Made resource format field read only. - Used core `if_empty_guess_format` validator for the field. - Modified choices into `openness_scores` for the Openness Score mappings on the format values.
Need business team support for this kind of a change, maybe you could demo it at dev chat? |
Just putting down some stuff we talked about:
In all, we want it to guess the format automatically, but then we also want users to be able to override this by being able to use a select2 input field to autocomplete to a specific list of allowed formats. The select2 field input would be a UX improvement and limit any possible misclicks in the current, long select list we have. This means that we do not need the format field to be required as it will validate and guess a format if empty. On the other hand, is this clear to the user in our current UI (need to add any messaging to the format field description?)? Note: the current openness score is already handled in this PR for any of the changes. |
…idator for resource format; - Added select2 scheming form snippet for specific display in our theme. - Added override action method for `format_autocomplete`. - Added custom validator to do format replacements based on `if_empty_guess_format` and `replaces`.
@wardi okay I worked on this concept a bit more and I think it is in a good place to show. The format field is now a select2 with the normal endpoint to the format autocomplete. However, I override the callback to get the choice values from our schema and match those without case sensitivity. And from my initial test, I was uploading a JPG image, and the I have also removed the EXE format from the choices during this. |
- Added labels and replaces checks for select2 callback. - Added TODOs.
As discussed, we are going to plan to get some front-end stuff happening. Which includes:
We will also have to confirm that the guess format works in the API. We should not change/simplify the API error message however, as that will NOT have a select2/type-ahead. We will also want to do something about the clear_upload in the back-end as well. |
# Conflicts: # ckanext/canada/plugins.py # ckanext/canada/validators.py # RESOLVED.
- Validator for guessing the resource format.
- Started frontend code for resource format. - Changed autocomplete to basic selectable select2 element. - Moved some code to reusable helper. - Added API util endpoint.
- Test for auto resource format.
feat(schemas): use core guess_format for resource format schema;
if_empty_guess_format
validator for the field.openness_scores
for the Openness Score mappings on the format values.I think we would like to have a custom validator, as the core one is
if_empty_guess_format
. I would like to keep this field read only as it seems like so many users do not select or type in the correct file formats.So there are the scenarios now that if a user cleared an upload or change it to a link, then the
if_empty_guess_format
would not fire off again hence theif_empty
. So doing aguess_format
which would just always set the format correctly.If the resource is a link and not upload however, what should we set the format to?